from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
class Base():
    # 初始化驱动
    def __init__(self,driver):
        self.driver = driver
    # 网址
    def open_url(self,url):
        self.driver.get(url)
    # 定位
    def find_element(self,loc):
        try:
            WebDriverWait(self.driver,20,0.5).until(lambda driver: driver.find_element(*loc).is_displayed())
            return self.driver.find_element(*loc)
        except Exception as e:
            print(e)
    # 输入
    def send_keys(self,url,info):
        self.find_element(url).send_keys(info)
    # 点击
    def click(self,url):
        self.find_element(url).click()
    # 回车
    def Enter(self,url):
        self.find_element(url).send_keys(Keys.ENTER)
    # 文本
    def text(self,url):
       return self.find_element(url).text



